//获取地址栏参数
function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}
//获取地址栏id参数
const id = getQueryString("id")
//根据id获取当前详情
console.log(id)



var goodlist = null
$.ajax({
    url: '../php/findGood.php',
    type: 'post',
    dataType: 'json',
    data: {
        id: id
    },
    success: function (res) {
        goodlist = res
        console.log(res)
        let str = ''
        goodlist.forEach(item => {
            str += `<div class="xm-product-box">
            <div class="nav-bar">
                <div class="container">
                    <h2>${item.goods_name}</h2>
                    <div class="right">
                        <a href="javasrcipt:;">用户评价</a>
                    </div>
                </div>
            </div>
        </div>
        <div class="page">
            <div class="product-box container">
                <div class="img-left clear_fix">
                    <img src="${item.datali_img}" alt="">
                </div>
                <div class="product-con clear_fix">
                    <h2>${item.goods_name}</h2>
                    <p class="sale-desc">
                    ${item.describe}
                    </p>
                    <div class="address-box">
                        <div class="prodect-address">
                            <i class="iconfont icon-icon-test"></i>
                            <div class="address-con">
                                <div class="title-ad">
                                    <span>安徽&nbsp;&nbsp;&nbsp;合肥市&nbsp;&nbsp;&nbsp;包河区&nbsp;&nbsp;&nbsp;徽州大道</span>
                                    <span class="au">修改</span>
                                </div>
                                <p>七日内发货</p>
                            </div>
                        </div>
                    </div>
                    <div class="btn-box">
                        <div class="sale-btn">
                            <a href="javasript:;" class="btn">立即购买</a>
                        </div>
                        <div class="cart-btn">
                            <a href="javasript:;" class="btn-cart">加入购物车</a>
                        </div>
                    </div>
                </div>
                <!-- 大图 -->
            </div>
            <div class="img">
                <div class="detail-banner  container">
                    <div class="img-tit">
                        商品详情
                    </div>
                    <div class="banban">
                        <img src="${item.bigfist}" alt="">
                        <img src="${item.bigtow}" alt="">
                        <img src="${item.bigthree}" alt="">
                    </div>
                </div>
            </div>
        </div>`
        })
        $('.ware').append($(str))
    }
})